package com.job.ZhangMeng;

/**
 * 2022.07.01  数组作业
 * 张孟
 */

public class Homework0701 {

    public static void main(String[] args) {
        //动态初始化数组，不指定数据
        int[] arr1=new int[3];

        //静态初始化数组，指定数据
        int[] arr2={0,1,2,3,4,5};

        //                  0       1       2       3       4       5
        String[] names={"Kai'sa","张孟","王中王","李元浩",null,"Jackeylove"};
        System.out.println(names.length);//length获取数组长度，null也占空间
        System.out.println(names[0]);//输出存放的第一个数据
        System.out.println(names[names.length-1]);//输出存放的最后一个数据(length=6,最后一位为names[5])
        System.out.println(names[3]+"发红包！");

        System.out.println();
        names[2]="王羲之";
        System.out.println(names[2]);

        //遍历
        for(int i=0;i<6;i++)
            System.out.println(i+"\t"+names[i]);
        System.out.println();
        for(int i=5;i>=0;i--)
            System.out.println(i+"~~~"+names[i]);
    }

}
